package com.example.yucheng.mapper;

import com.example.yucheng.domain.Warn;
import com.example.yucheng.util.PageQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WarnMapper {

    @Select("select * from warn")
    public List<Warn> getAllList();

    @Select("SELECT * FROM warn,stock where warn.g_id = stock.id order by warn.time desc limit #{pageNum},#{pageSize}")
    public List<Warn> getWarnByLimit(PageQuery pageQuery);

    @Select("SELECT * FROM warn,stock where warn.g_id = stock.id order by warn.time asc limit #{pageNum},#{pageSize}")
    public List<Warn> ascgetWarnByLimit(PageQuery pageQuery);

    @Select("SELECT warn.id,warn.g_id,stock.name,stock.number as stockNumber,warn.time,warn.number from warn,stock where warn.number > stock.number and warn.g_id=stock.id")
    public List<Warn> getIsWarnByLimit();

    @Delete("DELETE FROM warn WHERE id = #{id}")
    public int deleteWarnById(@Param("id") Integer id);

    @Insert("INSERT INTO warn (g_id,remark,number,time) VALUES( #{gId},#{remark},#{number},NOW())")
    public int insertWarn(Warn warn);

    @Update("UPDATE warn SET remark = #{remark},number = #{number} WHERE id = #{id}")
    public int updateWarn(Warn warn);
}
